package vo;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;

public class CourseVO implements Serializable {
	private static final long serialVersionUID = 1L;
	private String id;
	private String name;
	private String teacher;
	private String time;
	private String classroom;
	private String assistant;
	private HashMap<String, Integer> studentList;
	private HashMap<String, Integer> chooseList;
	private String type;
	private String semester;
	private String department;
	private boolean ifNecessary;
	private boolean ifZhunchu;
	private int studentNum;
	private int score;
	private int grade;
	private String remark;

	public CourseVO(String info) {
		String[] split = info.split(";");
		this.id = split[0];
		if (split.length > 11) {
			this.name = split[1];
			this.teacher = split[2];
			this.time = split[3];
			this.classroom = split[4];
			this.assistant = "";
			this.studentList = new HashMap<String, Integer>();
			this.chooseList = new HashMap<String, Integer>();
			this.type = split[5];
			this.semester = split[6];
			this.department = split[7];
			this.ifNecessary = Boolean.parseBoolean(split[8]);
			this.ifZhunchu = Boolean.parseBoolean(split[9]);
			this.studentNum = Integer.parseInt(split[10]);
			this.score = Integer.parseInt(split[11]);
			this.grade = Integer.parseInt(split[12]);
			this.remark = "";
		}
	}
	public CourseVO(String id, String name, String teacher, String time,
			String classroom, String assistant,
			HashMap<String, Integer> studentList,
			HashMap<String, Integer> chooseList, String type, String semester,
			String department, boolean ifNecessary, boolean ifZhunchu,
			int studentNum, int score, int grade, String remark) {
		super();
		this.id = id;
		this.name = name;
		this.teacher = teacher;
		this.time = time;
		this.classroom = classroom;
		this.assistant = assistant;
		this.studentList = studentList;
		this.chooseList = chooseList;
		this.type = type;
		this.semester = semester;
		this.department = department;
		this.ifNecessary = ifNecessary;
		this.ifZhunchu = ifZhunchu;
		this.studentNum = studentNum;
		this.score = score;
		this.grade = grade;
		this.remark = remark;
	}

	public CourseVO(String id, String name, String teacher, String time,
			String classroom, String type, String semester, String department,
			boolean ifNecessary, boolean ifZhunchu, int studentNum, int grade,
			String remark, int score) {
		super();
		this.id = id;
		this.name = name;
		this.teacher = teacher;
		this.time = time;
		this.classroom = classroom;
		this.type = type;
		this.semester = semester;
		this.department = department;
		this.ifNecessary = ifNecessary;
		this.ifZhunchu = ifZhunchu;
		this.studentNum = studentNum;
		this.grade = grade;
		this.remark = remark;
		this.score = score;
		this.studentList = new HashMap<>();
		this.chooseList = new HashMap<>();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTeacher() {
		return teacher;
	}

	public void setTeacher(String teacher) {
		this.teacher = teacher;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getClassroom() {
		return classroom;
	}

	public void setClassroom(String classroom) {
		this.classroom = classroom;
	}

	public String getAssistant() {
		return assistant;
	}

	public void setAssistant(String assistant) {
		this.assistant = assistant;
	}

	public HashMap<String, Integer> getStudentList() {
		return studentList;
	}

	public void setStudentList(HashMap<String, Integer> studentList) {
		this.studentList = studentList;
	}

	public HashMap<String, Integer> getChooseList() {
		return chooseList;
	}

	public void setChooseList(HashMap<String, Integer> chooseList) {
		this.chooseList = chooseList;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getSemester() {
		return semester;
	}

	public void setSemester(String semester) {
		this.semester = semester;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public boolean isIfNecessary() {
		return ifNecessary;
	}

	public void setIfNecessary(boolean ifNecessary) {
		this.ifNecessary = ifNecessary;
	}

	public boolean isIfZhunchu() {
		return ifZhunchu;
	}

	public void setIfZhunchu(boolean ifZhunchu) {
		this.ifZhunchu = ifZhunchu;
	}

	public int getStudentNum() {
		return studentNum;
	}

	public void setStudentNum(int studentNum) {
		this.studentNum = studentNum;
	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public int getGrade() {
		return grade;
	}

	public void setGrade(int grade) {
		this.grade = grade;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public int getNumNow() {
		return studentList.size() + chooseList.size();
	}

	public int getScore(String userId) {
		if (studentList == null)
			return 0;
		Iterator<String> iterator = studentList.keySet().iterator();
		while (iterator.hasNext()) {
			String student = iterator.next();
			String[] str = student.split(";");
			if (str[0].equals(userId)) {
				return studentList.get(student);
			}
		}
		return 0;
	}
}
